#include "co/co.h"
#include <QCoreApplication>
#include <QtTest>

// add necessary includes here
#include "frameless.h"

class Mco : public QObject {
    Q_OBJECT

public:
    Mco();
    ~Mco();

private slots:
    void test_case1();
    void wm();
};

Mco::Mco()
{
}

Mco::~Mco()
{
}

void Mco::test_case1()
{
    co::wait_group wg;
    wg.add(2);
    go([=]() {
        qDebug() << "sleep 1 sec";
        co::sleep(1000);
        wg.done();
    });

    go([=]() {
        co::sleep(3000);
        qDebug() << "sleep 3 sec";
        wg.done();
    });

    wg.wait();
}

void Mco::wm()
{
    QEventLoop loop;
    FrameLess fl;
    fl.show();
    connect(&fl, &QObject::destroyed, this, [&loop](QObject*) {
        loop.quit();
    });
    loop.exec();
}

QTEST_MAIN(Mco)

#include "tst_mco.moc"
